import java.util.Scanner;

/**
 * 需求分析
 * 1.键盘输入四位数字的会员卡号
 * 2.输出 各个位上的数字求和
 */
public class exercise01 {
    public static void main(String[] args) {
        String id;
        Scanner scanner = new Scanner(System.in);
        outer: //外层循环标签
        while (true) {
            System.out.println("请输入正确id卡号：");
            id = scanner.next();
            if (id.length() != 4) {
                System.out.println("id长度输入错误" + "\n=====================");
                continue;
            }
            for (int i = 0; i < 4; i++) {
                if (!(id.charAt(i) >= 48 && id.charAt(i) <= 57)) {
                    System.out.println("id输入错误，必须全部为数字" + "\n=====================");
                    continue outer;
                }
            }
            System.out.println("id输入成功");
            break;
        }

        memberCard memberCard = new memberCard(id);
        System.out.println("卡号："+memberCard.getId());
        System.out.println("卡号和："+memberCard.sumId());


    }
}